# 定义函数
def taxi_pay(distance):
    if distance <= 2:
        print("您需要支付8元")
    elif 2 < distance <= 12:
        cost = 8 + (distance-2)*1.5
        print(f"您需要支付{cost}元")
    elif 12 < distance:
        cost = 8 + 1.5*(12-2) + 2*(distance-12)
        print(f"您需要支付{cost}元")
# 调用函数
taxi_pay(distance = float(input("请输入要行驶的千米数（km）：")))